package com.zhouyiquan.dao.impl;

import com.zhouyiquan.dao.ProvinceDao;
import com.zhouyiquan.entity.Province;
import com.zhouyiquan.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * @author: 周益全（https://www.zhouyiquan.site）
 * @Date: Created in 2022/09
 * @Descript:
 */
public class ProvinceDaoImpl implements ProvinceDao {

    private JdbcTemplate templates = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public List<Province> findAll() {
        String sql = "select * from province";
        List<Province> list = templates.query(sql, new BeanPropertyRowMapper<Province>(Province.class));
        return list;
    }
}
